/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package MobileArchitecture.impl;

import MobileArchitecture.MobileArchitecturePackage;
import MobileArchitecture.Server;
import MobileArchitecture.ServerBO;
import MobileArchitecture.ServerDAO;
import MobileArchitecture.ServerEntity;
import MobileArchitecture.ServerService;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Server Entity</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link MobileArchitecture.impl.ServerEntityImpl#getService <em>Service</em>}</li>
 *   <li>{@link MobileArchitecture.impl.ServerEntityImpl#getDao <em>Dao</em>}</li>
 *   <li>{@link MobileArchitecture.impl.ServerEntityImpl#getBo <em>Bo</em>}</li>
 *   <li>{@link MobileArchitecture.impl.ServerEntityImpl#getServer <em>Server</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ServerEntityImpl extends NamedElementImpl implements ServerEntity {
	/**
	 * The cached value of the '{@link #getService() <em>Service</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getService()
	 * @generated
	 * @ordered
	 */
	protected ServerService service;

	/**
	 * The cached value of the '{@link #getDao() <em>Dao</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDao()
	 * @generated
	 * @ordered
	 */
	protected ServerDAO dao;

	/**
	 * The cached value of the '{@link #getBo() <em>Bo</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBo()
	 * @generated
	 * @ordered
	 */
	protected ServerBO bo;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ServerEntityImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return MobileArchitecturePackage.Literals.SERVER_ENTITY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ServerService getService() {
		return service;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetService(ServerService newService, NotificationChain msgs) {
		ServerService oldService = service;
		service = newService;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MobileArchitecturePackage.SERVER_ENTITY__SERVICE, oldService, newService);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setService(ServerService newService) {
		if (newService != service) {
			NotificationChain msgs = null;
			if (service != null)
				msgs = ((InternalEObject)service).eInverseRemove(this, MobileArchitecturePackage.SERVER_SERVICE__ENTITY, ServerService.class, msgs);
			if (newService != null)
				msgs = ((InternalEObject)newService).eInverseAdd(this, MobileArchitecturePackage.SERVER_SERVICE__ENTITY, ServerService.class, msgs);
			msgs = basicSetService(newService, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MobileArchitecturePackage.SERVER_ENTITY__SERVICE, newService, newService));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ServerDAO getDao() {
		return dao;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetDao(ServerDAO newDao, NotificationChain msgs) {
		ServerDAO oldDao = dao;
		dao = newDao;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MobileArchitecturePackage.SERVER_ENTITY__DAO, oldDao, newDao);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDao(ServerDAO newDao) {
		if (newDao != dao) {
			NotificationChain msgs = null;
			if (dao != null)
				msgs = ((InternalEObject)dao).eInverseRemove(this, MobileArchitecturePackage.SERVER_DAO__ENTITY, ServerDAO.class, msgs);
			if (newDao != null)
				msgs = ((InternalEObject)newDao).eInverseAdd(this, MobileArchitecturePackage.SERVER_DAO__ENTITY, ServerDAO.class, msgs);
			msgs = basicSetDao(newDao, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MobileArchitecturePackage.SERVER_ENTITY__DAO, newDao, newDao));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ServerBO getBo() {
		return bo;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetBo(ServerBO newBo, NotificationChain msgs) {
		ServerBO oldBo = bo;
		bo = newBo;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MobileArchitecturePackage.SERVER_ENTITY__BO, oldBo, newBo);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBo(ServerBO newBo) {
		if (newBo != bo) {
			NotificationChain msgs = null;
			if (bo != null)
				msgs = ((InternalEObject)bo).eInverseRemove(this, MobileArchitecturePackage.SERVER_BO__ENTITY, ServerBO.class, msgs);
			if (newBo != null)
				msgs = ((InternalEObject)newBo).eInverseAdd(this, MobileArchitecturePackage.SERVER_BO__ENTITY, ServerBO.class, msgs);
			msgs = basicSetBo(newBo, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MobileArchitecturePackage.SERVER_ENTITY__BO, newBo, newBo));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Server getServer() {
		if (eContainerFeatureID() != MobileArchitecturePackage.SERVER_ENTITY__SERVER) return null;
		return (Server)eContainer();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetServer(Server newServer, NotificationChain msgs) {
		msgs = eBasicSetContainer((InternalEObject)newServer, MobileArchitecturePackage.SERVER_ENTITY__SERVER, msgs);
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setServer(Server newServer) {
		if (newServer != eInternalContainer() || (eContainerFeatureID() != MobileArchitecturePackage.SERVER_ENTITY__SERVER && newServer != null)) {
			if (EcoreUtil.isAncestor(this, newServer))
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
			NotificationChain msgs = null;
			if (eInternalContainer() != null)
				msgs = eBasicRemoveFromContainer(msgs);
			if (newServer != null)
				msgs = ((InternalEObject)newServer).eInverseAdd(this, MobileArchitecturePackage.SERVER__ENTITIES, Server.class, msgs);
			msgs = basicSetServer(newServer, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MobileArchitecturePackage.SERVER_ENTITY__SERVER, newServer, newServer));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MobileArchitecturePackage.SERVER_ENTITY__SERVICE:
				if (service != null)
					msgs = ((InternalEObject)service).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MobileArchitecturePackage.SERVER_ENTITY__SERVICE, null, msgs);
				return basicSetService((ServerService)otherEnd, msgs);
			case MobileArchitecturePackage.SERVER_ENTITY__DAO:
				if (dao != null)
					msgs = ((InternalEObject)dao).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MobileArchitecturePackage.SERVER_ENTITY__DAO, null, msgs);
				return basicSetDao((ServerDAO)otherEnd, msgs);
			case MobileArchitecturePackage.SERVER_ENTITY__BO:
				if (bo != null)
					msgs = ((InternalEObject)bo).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MobileArchitecturePackage.SERVER_ENTITY__BO, null, msgs);
				return basicSetBo((ServerBO)otherEnd, msgs);
			case MobileArchitecturePackage.SERVER_ENTITY__SERVER:
				if (eInternalContainer() != null)
					msgs = eBasicRemoveFromContainer(msgs);
				return basicSetServer((Server)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MobileArchitecturePackage.SERVER_ENTITY__SERVICE:
				return basicSetService(null, msgs);
			case MobileArchitecturePackage.SERVER_ENTITY__DAO:
				return basicSetDao(null, msgs);
			case MobileArchitecturePackage.SERVER_ENTITY__BO:
				return basicSetBo(null, msgs);
			case MobileArchitecturePackage.SERVER_ENTITY__SERVER:
				return basicSetServer(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
		switch (eContainerFeatureID()) {
			case MobileArchitecturePackage.SERVER_ENTITY__SERVER:
				return eInternalContainer().eInverseRemove(this, MobileArchitecturePackage.SERVER__ENTITIES, Server.class, msgs);
		}
		return super.eBasicRemoveFromContainerFeature(msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case MobileArchitecturePackage.SERVER_ENTITY__SERVICE:
				return getService();
			case MobileArchitecturePackage.SERVER_ENTITY__DAO:
				return getDao();
			case MobileArchitecturePackage.SERVER_ENTITY__BO:
				return getBo();
			case MobileArchitecturePackage.SERVER_ENTITY__SERVER:
				return getServer();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case MobileArchitecturePackage.SERVER_ENTITY__SERVICE:
				setService((ServerService)newValue);
				return;
			case MobileArchitecturePackage.SERVER_ENTITY__DAO:
				setDao((ServerDAO)newValue);
				return;
			case MobileArchitecturePackage.SERVER_ENTITY__BO:
				setBo((ServerBO)newValue);
				return;
			case MobileArchitecturePackage.SERVER_ENTITY__SERVER:
				setServer((Server)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MobileArchitecturePackage.SERVER_ENTITY__SERVICE:
				setService((ServerService)null);
				return;
			case MobileArchitecturePackage.SERVER_ENTITY__DAO:
				setDao((ServerDAO)null);
				return;
			case MobileArchitecturePackage.SERVER_ENTITY__BO:
				setBo((ServerBO)null);
				return;
			case MobileArchitecturePackage.SERVER_ENTITY__SERVER:
				setServer((Server)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MobileArchitecturePackage.SERVER_ENTITY__SERVICE:
				return service != null;
			case MobileArchitecturePackage.SERVER_ENTITY__DAO:
				return dao != null;
			case MobileArchitecturePackage.SERVER_ENTITY__BO:
				return bo != null;
			case MobileArchitecturePackage.SERVER_ENTITY__SERVER:
				return getServer() != null;
		}
		return super.eIsSet(featureID);
	}

} //ServerEntityImpl
